import {getUserBasicInformation} from "@/api/system/user";
import store from "@/store";

export async function getUserAvatar(userId) {
  console.log(userId);
  if (!userId && typeof userId !== 'number' && !(typeof userId === 'string' && !isNaN(Number(userId)))) return null;
  let userAvatar = store.state.userAvatar.userAvatars
  console.log(userAvatar.get(userId));
  if (userAvatar.get(userId)) {
    return userAvatar.get(userId);
  } else {
    const {data} = await getUserBasicInformation(userId);
    await store.dispatch("userAvatar/setUserAvatars", data)
    return data
  }
}
